<template>
    <view>
		<view style="margin-left: 20rpx;margin-right: 20rpx;font-size: 15px;">
		 <u-parse :content="content" />
		</view>

        <!--加载框 start-->
        <tui-loading :visible="loading"></tui-loading>
        <!--加载框 end-->
    </view>
</template>

<script>
import uParse from '@/components/gaoyia-parse/parse.vue'
import tuiLoading from "../../components/loading/loading";
/*
* Author: 郭少
* github: https://github.com/guoshao99/wallpaper-applet
* gitee: https://gitee.com/guoshao99/wallpaper-applet
* QQ：2549789059
* 微信：2549789059
*/
const Constant = require('../../utils/constants');

const util = require('../../utils/util.js');


const http = require('../../utils/http.js');

let setinad;
export default {
		components: {
		  tuiLoading,
		  uParse
		},
		data() {
            return {
              pagead: 2,
              pageadB: 0,
              thisPage: 'notice',
              noticeId: '',

              noticeObj: {
                content: ""
              },

              content: "",

              setAD: {
                banner: "",
                videoid: "",
                gridid: "",
                customAid: "",
                customBid: "",
                customCid: ""
              },

              loading: false
            };
        },
onLoad: function (options) {
  this.setData({
    noticeId: options.id
  });
  this.loadNotice();
},
onShow(options) {
  var that = this;
  /*util.getAD(that, function () {
    that.setInterstitialAd(); //加载插屏广告
  }, that.data.thisPage);*/

  /*
  * WxParse.wxParse(bindName , type, data, target,imagePadding)
  * 1.bindName绑定的数据名(必填)
  * 2.type可以为html或者md(必填)
  * 3.data为传入的具体数据(必填)
  * 4.target为Page对象,一般为this(必填)
  * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
  */
},
onHide() {
  clearInterval(setinad);
},
onShareAppMessage: function () {
  var that = this;
  uni.showShareMenu({
    withShareTicket: true,
    menus: ['shareAppMessage', 'shareTimeline']
  });
  return {
    title: that.shares.share_title,
    imageUrl: that.shares.share_image
  };
},
//转发朋友圈
onShareTimeline: function () {
  var that = this;
  return {
    title: that.shares.share_title,
    imageUrl: that.shares.share_image
  };
},
// 收藏
onAddToFavorites: function () {
  var that = this;
  return {
    title: that.shares.share_title,
    imageUrl: that.shares.share_image
  };
},
methods: {
    // 获取小程序插屏广告
    setInterstitialAd: function () {
      var that = this;

      if (that.setAD.interstitialid && uni.createInterstitialAd) {
        let interstitialAd = uni.createInterstitialAd({
          adUnitId: that.setAD.interstitialid
        }); // 监听插屏错误事件

        interstitialAd.onError(err => {
          console.error(err);
        }); // 显示广告

        if (interstitialAd) {
          if (that.setAD.switch_inad == 'yes') {
            setinad = setInterval(() => {
              interstitialAd.show().catch(err => {
                console.error(err);
              });
            }, 2000);
          } else {
            setTimeout(() => {
              interstitialAd.show().catch(err => {
                console.error(err);
              });
            }, 6000);
          }
        }
      }
    },

    copy: function (e) {
      let text = e.currentTarget.dataset.text;
      uni.setClipboardData({
        data: text,

        success(res) {
          uni.getClipboardData({
            success(res) {
              uni.showToast({
                title: '微信号已复制'
              });
            }

          });
        }

      });
    },

    tipClick: function () {
      uni.showToast({
        icon: 'none',
        title: 'v1.1.8'
      });
    },

    loadNotice: function () {
      let that = this;
      var params = {
        url: "/notice/getById",
        method: "GET",
        data: {
          id: that.noticeId
        },
        callBack: function (res) {
          if (res.code == 200) {
            that.content = that.escape2Html(res.data.content);
			console.log(that.content);
            that.setData({
              noticeObj: res.data
            });
          } else {
            uni.showToast({
              title: res.msg,
              icon: 'fail',
              duration: 2000
            });
          }
        }
      };
      http.request(params);
    }
}
                };
</script>
<style>
@import url("/components/gaoyia-parse/parse.css");
@import './notice.css';
</style>
